package org.meteorshower.cms_common.exception;


import org.meteorshower.cms_common.result.ResponseObj;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(ParameterNullPointException.class)
    public ResponseObj handleServiceException(ParameterNullPointException e) {
        e.printStackTrace();
        return ResponseObj.error(e.getMessage());
    }
    @ExceptionHandler(ResultNullPointException.class)
    public ResponseObj handleServiceException(ResultNullPointException e) {
        e.printStackTrace();
        return ResponseObj.fail(e.getMessage());
    }
    @ExceptionHandler(RecordExitException.class)
    public ResponseObj handleServiceException(RecordExitException e) {
        e.printStackTrace();
        return ResponseObj.fail(e.getMessage());
    }
    @ExceptionHandler(UnknownRecordException.class)
    public ResponseObj handleServiceException(UnknownRecordException e) {
        e.printStackTrace();
        return ResponseObj.fail(e.getMessage());
    }
    @ExceptionHandler(ServiceException.class)
    public ResponseObj handleServiceException(ServiceException e) {
        e.printStackTrace();
        return ResponseObj.error(e.getMessage());
    }
    @ExceptionHandler(Exception.class)
    public ResponseObj handleException(Exception e) {
        e.printStackTrace();
        return ResponseObj.error();
    }
}
